<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr=["星期一","星期二","星期三","星期四","星期五","星期六","星期日"]
        let arr1=new Array("星期一","星期二","星期三","星期四","星期五","星期六","星期日")
        for(let i=0;i<arr.length;i++){
            console.log(arr[i])
        }
        let n=0
        while(n<arr1.length){
            console.log(arr1[n])
            n++
        }
        function add(x,y){
            return x+y
        }
        function mul(x,y){
            return x*y
        }
        function sub(x,y){
            return x-y
        }
        function computer(x,y,fun){
            return fun(x,y)
        }
        let r=computer(2,3,add)
        console.log(r)
        let z =computer(2,6,mul)
        console.log(z)

        let num=[1,2,3,4,5]
        let double=num.map(num=>num*2)
        console.log(double)

        let evens=num.filter(num=>num%2===0)
        console.log(evens)

        let fruits=["apple","banana","mango","strawberry","lemon"]
        fruits.forEach(fruits=>{
            console.log(`I love ${fruits}`)
        })

        let hasEven=num.some(num=>num%2===0)
        console.log(hasEven)
        let allEven=num.every(num=>num%2===0)
        console.log(allEven)

        num.sort((a, b) => a - b)
        console.log(num)
        num.sort((a, b) => b - a)
        console.log(num)
        let sum=num.reduce((a,b)=>{
            return a+b
        },0)
        console.log(sum)
        let users=[{ id: 1, name: 'Alice' },
        { id: 2, name: 'Bob' }]
        let user=users.find(u => u.id === 2)
        console.log(user)
    </script>
</body>
</html>